﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web.Admin.Page
{
    public partial class SinglePage : Evan.WebUI.DetailManager
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                bool HasRole = Evan.Member.Administrator.HasRole(1, ClassId.ToString(), "", "view");
                VerifyRoles(HasRole);

                string curTitle = Evan.Model.ConvertModel.HasKey(Model, "Title") ? Model.Title : "";
                Evan.SystemLog.SysLog.AddSysLog("查看 [" + curTitle + "] 单页内容", "查看单页内容 [表名称=" + TableName + "] , [栏目名称=" + CurChannel.Title + "] , [内容名称=" + curTitle + "]");
            }
        }

        public bool IsViewEdit(string entitle, int pagetype)
        {
            string pageurl = "";
            string checkname = "";
            switch (pagetype)
            {
                case 1:
                    pageurl = "News";
                    checkname = "~/App_Data/Template/" + pageurl + "/" + entitle.Replace(" ", "_") + "/detail_edit.html";
                    break;
                case 3:
                    pageurl = "SinglePage";
                    checkname = "~/App_Data/Template/" + pageurl + "/" + entitle.Replace(" ", "_") + "/index_edit.html";
                    break;
            }
            

            if (System.IO.File.Exists(Server.MapPath(checkname)))
            {
                return true;
            }
            else
            {
                return false;
            }
            //return false;
        }
    }
}